feat(compression): adapt Huffman coding to current architecture#22
Merged
Conversation
- Add Huffman coding algorithm for lossless data compression, including detailed descriptions and steps for visualization. - Introduce new `HuffmanState` type for managing the algorithm's state during visualization. - Update translations to include new algorithm and its description in both English and Spanish. - Modify `package.json` to override Vite version for compatibility. This commit enhances the compression category with a foundational algorithm widely used in data compression. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> # Conflicts: # src/components/ConceptVisualizer.tsx # src/i18n/translations.ts # src/lib/algorithms/index.ts
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR adds Huffman Coding as a new Compression algorithm in the alg0.dev catalog, adapting the original contribution to the current lazy-loaded Algorithm module + plain-DOM “concept” visualizer architecture.
Changes:
- Introduces a new Compression category and registers Huffman Coding across SSR algorithm lists, catalog ordering, routing/loaders, and i18n category labels.
- Adds a new concept visualizer (
huffman) plus a step generator that drives the visualization through frequency counting, tree building, and code assignment. - Adds lazy-loaded non-JS code implementations (Python/Java/C++/Rust) wired into the language pack loaders.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/visualizers/concept/index.ts | Registers the new huffman concept renderer via dynamic import. |
| src/lib/visualizers/concept/huffman.ts | Implements the Huffman concept visualizer (tree + node table + summary). |
| src/lib/types.ts | Adds HuffmanState and extends ConceptState to support the new visualizer state. |
| src/lib/categories.ts | Adds Compression slug + intro copy (EN/ES). |
| src/lib/algorithms/loaders.ts | Adds huffman-coding algorithm loader and compression implementation group loaders. |
| src/lib/algorithms/index.ts | Adds huffmanCoding to the SSR algorithm list and adds Compression to categories. |
| src/lib/algorithms/catalog.ts | Adds catalog entry for Huffman Coding and includes Compression in category ordering. |
| src/lib/algorithms/compression.ts | Adds the Huffman Coding algorithm module + step generator used by the concept visualizer. |
| src/lib/algorithms/python/index.ts | Wires Compression implementations into the Python pack. |
| src/lib/algorithms/python/compression.ts | Adds annotated Huffman implementation in Python. |
| src/lib/algorithms/java/index.ts | Wires Compression implementations into the Java pack. |
| src/lib/algorithms/java/compression.ts | Adds annotated Huffman implementation in Java. |
| src/lib/algorithms/cpp/index.ts | Wires Compression implementations into the C++ pack. |
| src/lib/algorithms/cpp/compression.ts | Adds annotated Huffman implementation in C++. |
| src/lib/algorithms/rust/index.ts | Wires Compression implementations into the Rust pack. |
| src/lib/algorithms/rust/compression.ts | Adds annotated Huffman implementation in Rust. |
| src/i18n/translations.ts | Adds translated category label for Compression (EN/ES). |
| src/content/algorithms/huffman-coding.ts | Adds long-form Huffman Coding description content (EN/ES). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+78
to
+82
| nodeStates?: Record<number, HNodeState> | ||
| highlightChar?: string | null | ||
| freqTable?: { char: string; freq: number; active?: boolean }[] | ||
| codes?: { char: string; code: string; freq: number; active?: boolean }[] | ||
| activeCode?: string | null |
Comment on lines
+18
to
+23
| Time Complexity: | ||
| Best: O(n log n) | ||
| Average: O(n log n) | ||
| Worst: O(n log n) | ||
|
|
||
| Space Complexity: O(n) |
Comment on lines
+45
to
+50
| Complejidad Temporal: | ||
| Mejor: O(n log n) | ||
| Promedio: O(n log n) | ||
| Peor: O(n log n) | ||
|
|
||
| Complejidad Espacial: O(n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Supersedes #16 with an implementation based on the current architecture.
Validation
pnpm build